import 'dart:convert';

T? asT<T>(dynamic value) {
  if (value is T) {
    return value;
  }
  return null;
}

class RechargeOrderModel {
  RechargeOrderModel({
    this.devId,
    this.amount,
    this.price,
    this.days,
    this.id,
    this.day,
    this.giftDays,
    this.createDateTime,
    this.serviceDate,
  });

  factory RechargeOrderModel.fromJson(Map<String, dynamic> jsonRes) => RechargeOrderModel(
        devId: asT<String>(jsonRes['devId']),
        amount: asT<double>(jsonRes['amount']),
        price: asT<String>(jsonRes['price']),
        days: asT<int>(jsonRes['days']),
        id: asT<int>(jsonRes['id']),
        day: asT<int>(jsonRes['day']),
        giftDays: asT<int>(jsonRes['giftDays']),
        createDateTime: asT<String>(jsonRes['createDateTime']),
        serviceDate: asT<String>(jsonRes['serviceDate']),
      );

  String? devId;
  double? amount;
  String? price;
  int? days;
  int? id;
  int? day;
  int? giftDays;
  String? createDateTime;
  String? serviceDate; //服务日期

  @override
  String toString() {
    return jsonEncode(this);
  }

  Map<String, dynamic> toJson() => <String, dynamic>{
        'devId': devId,
        'amount': amount,
        'price': price,
        'days': days,
        'id': id,
        'day': day,
        'giftDays': giftDays,
        'createDateTime': createDateTime,
        'serviceDate': serviceDate,
      };
}
